<%def name="prepopulated_fields(values, prepopulated_fields)">
<script type="text/javascript">
(function($) {
    var field = null;

% for field in prepopulated_fields:
    field = {
        id: '#${ field['field'].auto_id }',
        dependency_ids: [],
        dependency_list: [],
        maxLength: ${ field['field'].field.max_length or 50 }
    };
% for dependency in field['dependencies']:
    field['dependency_ids'].push('#${ dependency.auto_id }');
    field['dependency_list'].push('.${ dependency.name }');
% endfor

    $('.empty-form .${ field['field'].name }').addClass('prepopulated_field');
    $(field.id).data('dependency_list', field['dependency_list'])
               .prepopulate($(field['dependency_ids'].join(',')), field.maxLength);
% endfor
})(django.jQuery);
</script>
</%def>
            
